package org.seckill.enums;

/**
 * @description:
 * @author: jason.jia
 * @create: 2018-11-11 16:39
 **/
public enum  SeckillStatEnums {
    SUCCESS(0,"秒杀成功"),
    END(1,"秒杀结束"),
    REPEAT_KILL(-1,"重复秒杀"),
    INNER_ERROR(-2,"系统异常"),
    data_rewrite(-3,"数据篡改")
    ;

    private int state;

    private String stateInfo;

    SeckillStatEnums(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    public static SeckillStatEnums stateOf(int index){
        for (SeckillStatEnums s:values()){
            if(s.getState() == index){
                return s;
            }
        }
        return null;
    }
}
